#include <gtk/gtk.h>   
#include <gst/gst.h>   
#include <signal.h>   
#include <string.h>   
#include <gst/interfaces/xoverlay.h>
#include <glade/glade.h>
#include <time.h>

#include "config.h"
#include "mp4_player.h"
#include "gif_player.h"
#include "jpg_player.h"
#include "socket_client.h"
#include "printer_local.h"
#include "message_handler.h"
#include "xml_client.h"
#include "sys_time.h"
#include "keyboard.h"
#include "sys_log.h"
#include "url_config_win.h"


static gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data ) 
{ 
	SYS_LOG("delete event occerred"); 
	return(FALSE); 
} 

static void destroy( GtkWidget *widget, gpointer data ) 
{ 
} 

static GtkWindow *show_text_u_in_new_win(GtkWidget *view, char* text,int size) 
{
	gchar *markup;

	if(!text || !view) {
		SYS_LOG("show_text_in_new_win error\n");
		return NULL;
	}

	int str_len = strlen(text);

	
//	markup=g_markup_printf_escaped("<span size=\"30000\" foreground=\"black\" >%s</span>",size,text);
	markup=g_markup_printf_escaped("<span size=\"%d\" foreground=\"black\" >%s</span>",size,text);

	gtk_label_set_markup(GTK_LABEL(view),markup);
	g_free( (gpointer)markup );
	
	gtk_widget_show(view);

	return NULL;
}

static void
update_widget_bg(GtkWidget *widget, gchar *img_file, int w, int h)
{		
	GdkPixbuf *src_pixbuf;		
	GdkPixbuf *dst_pixbuf;	   
	GtkWidget	*image;
	gint width, height;    

	if(NULL == widget) {
		SYS_LOG ("update_widget_bg widget NULL");
		return;
	}

	if(-1 == access(img_file,F_OK)){
		SYS_LOG ("file not exist");
		return;
	}
	
	src_pixbuf = gdk_pixbuf_new_from_file(img_file, NULL);	  
	width = gdk_pixbuf_get_width(src_pixbuf);	
	height = gdk_pixbuf_get_height(src_pixbuf);    

	if (src_pixbuf ==NULL){   
		  SYS_LOG ("pixbuf create failed");
		  return;
	}
	dst_pixbuf=gdk_pixbuf_scale_simple(src_pixbuf,w,h,GDK_INTERP_BILINEAR);

	gtk_image_set_from_pixbuf((GtkImage *)widget,dst_pixbuf);	 
	g_object_unref(src_pixbuf); 
	g_object_unref(dst_pixbuf);
	
}

static GtkWidget *new_widget_bg(GtkWidget *widget, gchar *img_file, int w, int h)
{		
	GdkPixbuf *src_pixbuf;		
	GdkPixbuf *dst_pixbuf;	   
	GtkWidget	*image;
	gint width, height;    


	if(-1 == access(img_file,F_OK)) {
		SYS_LOG ("file not exist");
		return;
	}
	
	src_pixbuf = gdk_pixbuf_new_from_file(img_file, NULL);	  
	width = gdk_pixbuf_get_width(src_pixbuf);	
	height = gdk_pixbuf_get_height(src_pixbuf);    

	if (src_pixbuf ==NULL){   
		  SYS_LOG ("pixbuf create failed");
		  return;
	}
	dst_pixbuf=gdk_pixbuf_scale_simple(src_pixbuf,w,h,GDK_INTERP_BILINEAR);

	image=gtk_image_new();
	gtk_widget_set_size_request(image,w,h);
	gtk_image_set_from_pixbuf((GtkImage *)image,dst_pixbuf);	 
	g_object_unref(src_pixbuf); 
	g_object_unref(dst_pixbuf); 
    gtk_container_add(GTK_CONTAINER(widget),image);
	return image;
	
}


static GtkWidget *four_gui_builder_set_left(GtkBuilder *builder,print_sys_config_s *sys_config)
{
	GtkFixed *fixed2 = GTK_FIXED(gtk_builder_get_object (builder, "fixed2"));

	//set left box bg
	GtkWidget *bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed2_image_bg1"));
	gtk_fixed_move(GTK_FIXED(fixed2),bg,0,0);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_main_ad_w,sys_config->fs_main_ad_h);
	
	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed2_image_bg2"));
	gtk_fixed_move(GTK_FIXED(fixed2),bg,0,sys_config->fs_main_ad_h+sys_config->fs_pad);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_little_ad_w,sys_config->fs_little_ad_h);

	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed2_image_bg3"));
	gtk_fixed_move(GTK_FIXED(fixed2),bg,sys_config->fs_little_ad_w+sys_config->fs_pad,sys_config->fs_main_ad_h+sys_config->fs_pad);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_little_ad_w,sys_config->fs_little_ad_h);

	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed2_image_bg4"));
	gtk_fixed_move(fixed2,bg,2*(sys_config->fs_little_ad_w+sys_config->fs_pad),sys_config->fs_main_ad_h+sys_config->fs_pad);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_little_ad_w,sys_config->fs_little_ad_h);
	
	//set left ad
	if(0 == strcmp(sys_config->sys_config.screen_module,"four_gui_jpg")){
		SYS_LOG ("four_gui_jpg\n");

		sys_config->image_ad_main = GTK_WIDGET(gtk_builder_get_object (builder, "image_ad_main"));
		gtk_fixed_move(fixed2,sys_config->image_ad_main,sys_config->fs_pad,sys_config->fs_pad);
		gtk_widget_set_size_request(sys_config->image_ad_main,sys_config->fs_main_ad_w-2*sys_config->fs_pad,sys_config->fs_main_ad_h-2*sys_config->fs_pad);
		update_widget_bg(sys_config->image_ad_main,sys_config->sys_config.main_ad,sys_config->fs_main_ad_w-2*sys_config->fs_pad,sys_config->fs_main_ad_h-2*sys_config->fs_pad);

	} else {
		sys_config->frame_movie = GTK_WIDGET(gtk_builder_get_object (builder, "framemovie"));
		gtk_fixed_move(fixed2,sys_config->frame_movie,sys_config->fs_pad,sys_config->fs_pad);
		gtk_widget_set_size_request(sys_config->frame_movie,sys_config->fs_main_ad_w-2*sys_config->fs_pad,sys_config->fs_main_ad_h-2*sys_config->fs_pad);
	}
	
	sys_config->image_ad_left = GTK_WIDGET(gtk_builder_get_object (builder, "image_ad_left"));
	gtk_fixed_move(fixed2,sys_config->image_ad_left,sys_config->fs_pad,sys_config->fs_main_ad_h+2*sys_config->fs_pad);
	gtk_widget_set_size_request(sys_config->image_ad_left,(sys_config->fs_little_ad_w-2*sys_config->fs_pad),(sys_config->fs_little_ad_h-2*sys_config->fs_pad));
	update_widget_bg(sys_config->image_ad_left,sys_config->sys_config.left_ad,(sys_config->fs_little_ad_w-2*sys_config->fs_pad),(sys_config->fs_little_ad_h-2*sys_config->fs_pad));
	
	sys_config->image_ad_middle = GTK_WIDGET(gtk_builder_get_object (builder, "image_ad_middle"));
	gtk_fixed_move(fixed2,sys_config->image_ad_middle,sys_config->fs_little_ad_w+2*sys_config->fs_pad,sys_config->fs_main_ad_h+2*sys_config->fs_pad);
	gtk_widget_set_size_request(sys_config->image_ad_middle,(sys_config->fs_little_ad_w-2*sys_config->fs_pad),(sys_config->fs_little_ad_h-2*sys_config->fs_pad));
	update_widget_bg(sys_config->image_ad_middle,sys_config->sys_config.middle_ad,(sys_config->fs_little_ad_w-2*sys_config->fs_pad),(sys_config->fs_little_ad_h-2*sys_config->fs_pad));

	sys_config->image_ad_right = GTK_WIDGET(gtk_builder_get_object (builder, "image_ad_right"));
	gtk_fixed_move(fixed2,sys_config->image_ad_right,2*sys_config->fs_little_ad_w+3*sys_config->fs_pad,sys_config->fs_main_ad_h+2*sys_config->fs_pad);
	gtk_widget_set_size_request(sys_config->image_ad_right,(sys_config->fs_little_ad_w-2*sys_config->fs_pad),(sys_config->fs_little_ad_h-2*sys_config->fs_pad));
	update_widget_bg(sys_config->image_ad_right,sys_config->sys_config.right_ad,(sys_config->fs_little_ad_w-2*sys_config->fs_pad),(sys_config->fs_little_ad_h-2*sys_config->fs_pad));

}

static GtkWidget *four_gui_builder_set_right(GtkBuilder *builder,print_sys_config_s *sys_config)
{
	GtkFixed *fixed3 = GTK_FIXED(gtk_builder_get_object (builder, "fixed3"));

	//set right box bg
	GtkWidget *bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed3_image_bg1"));
	gtk_fixed_move(fixed3,bg,0,sys_config->fs_logo_img_h+sys_config->fs_pad);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_right_fix_w,sys_config->fs_code_text_h);

	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed3_image_bg2"));
	gtk_fixed_move(fixed3,bg,0,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+2*sys_config->fs_pad);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_qr_img_w,sys_config->fs_qr_img_h);

	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed3_image_bg3"));
	gtk_fixed_move(fixed3,bg,0,sys_config->fs_logo_img_h+sys_config->fs_qr_img_h+sys_config->fs_code_text_h+3*sys_config->fs_pad);
	update_widget_bg(bg,sys_config->sys_config.image_bg,sys_config->fs_usr_text_w,sys_config->fs_usr_text_h);

	
//set right 
	//set logo
	sys_config->image_logo = GTK_WIDGET(gtk_builder_get_object (builder, "image_logo"));
	gtk_fixed_move(fixed3,sys_config->image_logo,0,0);
	gtk_widget_set_size_request(sys_config->image_logo,sys_config->fs_logo_img_w,sys_config->fs_logo_img_h);
	update_widget_bg(sys_config->image_logo,sys_config->sys_config.image_logo,sys_config->fs_logo_img_w,sys_config->fs_logo_img_h);

	//set label code ---fixed3_bg1
	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed3_label_1"));
	gtk_fixed_move(fixed3,bg,2*sys_config->fs_pad,sys_config->fs_logo_img_h+2*sys_config->fs_pad);
	show_text_u_in_new_win(bg,"微信验证码 :",20000);
	
	sys_config->label_code = GTK_WIDGET(gtk_builder_get_object (builder, "label_code"));
	gtk_fixed_move(fixed3,sys_config->label_code,(sys_config->fs_right_fix_w)/2+sys_config->fs_pad,sys_config->fs_logo_img_h+2*sys_config->fs_pad);
    if (0 == strcmp(sys_config->sys_config.printer_mode,"free")) {
        show_text_u_in_new_win(sys_config->label_code,sys_config->sys_config.code,20000);
    }
	//set qr ---fixed3_bg2
	sys_config->image_qr_code = GTK_WIDGET(gtk_builder_get_object (builder, "image_qr_code"));
	gtk_fixed_move(fixed3,sys_config->image_qr_code,sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+3*sys_config->fs_pad);
	gtk_widget_set_size_request(sys_config->image_qr_code,(sys_config->fs_qr_img_w-2*sys_config->fs_pad)/2,sys_config->fs_qr_img_h-2*sys_config->fs_pad);
	update_widget_bg(sys_config->image_qr_code,sys_config->sys_config.image_qr,(sys_config->fs_qr_img_w-2*sys_config->fs_pad)/2,sys_config->fs_qr_img_h-2*sys_config->fs_pad);


	bg = GTK_WIDGET(gtk_builder_get_object (builder, "fixed3_label_2"));
	gtk_fixed_move(fixed3,bg,sys_config->fs_qr_img_w/2+sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+5*sys_config->fs_pad);
	show_text_u_in_new_win(bg,"扫一扫关注我",20000);

	sys_config->label_time= GTK_WIDGET(gtk_builder_get_object (builder, "label_time"));
	gtk_fixed_move(fixed3,sys_config->label_time,sys_config->fs_qr_img_w/2+sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h/2+4*sys_config->fs_pad);
	settime(sys_config->label_time,17000);


	//set detail ----fixed bg 3
	int usr_text_h  = (sys_config->fs_usr_text_h-7*sys_config->fs_pad)/8;
	bg = GTK_WIDGET(gtk_builder_get_object (builder, "right_fixed_label_1"));
	gtk_fixed_move(fixed3,bg,sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h+4*sys_config->fs_pad);
	show_text_u_in_new_win(bg,sys_config->sys_config.right_fixed_label_1,20000);

	bg = GTK_WIDGET(gtk_builder_get_object (builder, "right_fixed_label_2"));
	gtk_fixed_move(fixed3,bg,sys_config->fs_right_fix_w/4,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h+usr_text_h+5*sys_config->fs_pad);
	show_text_u_in_new_win(bg,sys_config->sys_config.right_fixed_label_2,30000);

	sys_config->label_text_1= GTK_WIDGET(gtk_builder_get_object (builder, "right_label_1"));
	gtk_fixed_move(fixed3,sys_config->label_text_1,3*sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h+3*usr_text_h+6*sys_config->fs_pad);
	show_text_u_in_new_win(sys_config->label_text_1,sys_config->sys_config.right_label_1,20000);
	
	sys_config->label_text_2= GTK_WIDGET(gtk_builder_get_object (builder, "right_label_2"));
	gtk_fixed_move(fixed3,sys_config->label_text_2,3*sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h+4*usr_text_h+7*sys_config->fs_pad);	
	show_text_u_in_new_win(sys_config->label_text_2,sys_config->sys_config.right_label_2,20000);

	sys_config->label_text_3= GTK_WIDGET(gtk_builder_get_object (builder, "right_label_3"));
	gtk_fixed_move(fixed3,sys_config->label_text_3,3*sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h+5*usr_text_h+8*sys_config->fs_pad);
	show_text_u_in_new_win(sys_config->label_text_3,sys_config->sys_config.right_label_3,20000);

	sys_config->label_text_4= GTK_WIDGET(gtk_builder_get_object (builder, "right_label_4"));
	gtk_fixed_move(fixed3,sys_config->label_text_4,3*sys_config->fs_pad,sys_config->fs_logo_img_h+sys_config->fs_code_text_h+sys_config->fs_qr_img_h+6*usr_text_h+9*sys_config->fs_pad);
	show_text_u_in_new_win(sys_config->label_text_4,sys_config->sys_config.right_label_4,20000);

	//set device_id
	sys_config->device_id_text = GTK_WIDGET(gtk_builder_get_object (builder, "device_id"));
	gtk_fixed_move(fixed3,sys_config->device_id_text, sys_config->fs_right_fix_w/2 - 2*sys_config->fs_pad,sys_config->fs_right_fix_h-sys_config->fs_pad/2);
	show_text_u_in_new_win(sys_config->device_id_text,sys_config->sys_config.device_id,10000);
//end

}

GtkWidget *four_gui_builder(print_sys_config_s *sys_config)  
{  
	GtkBuilder *builder;
	GtkWidget *window = NULL; 
	
	builder = gtk_builder_new();
	gtk_builder_add_from_file(builder,"./res/four_gui.glade", NULL );
	window = GTK_WIDGET(gtk_builder_get_object (builder, "main_win"));
	gtk_builder_connect_signals(builder, NULL );

	if(!window)
	SYS_LOG ("window null\n");

	//set window size

	gtk_window_set_default_size(GTK_WINDOW(window), sys_config->screen_w, sys_config->screen_h);
    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
    gtk_window_fullscreen(GTK_WINDOW(window));

// gtk_fixed_move( GtkFixed *fixed,GtkWidget *widget,gint x,gint y );


	/*set screen value*/
	//left
	sys_config->fs_pad = 10;
	sys_config->fs_frame_img_w=sys_config->screen_w*0.95;
	sys_config->fs_frame_img_h=sys_config->screen_h*0.95;

	sys_config->fs_left_fix_w=(sys_config->fs_frame_img_w-3*sys_config->fs_pad)*0.8;
	sys_config->fs_left_fix_h=sys_config->fs_frame_img_h-2*sys_config->fs_pad;

	sys_config->fs_right_fix_w= sys_config->fs_frame_img_w-sys_config->fs_left_fix_w-sys_config->fs_pad;
	sys_config->fs_right_fix_h = sys_config->fs_frame_img_h-2*sys_config->fs_pad;

	sys_config->fs_main_ad_w = sys_config->fs_left_fix_w-2*sys_config->fs_pad;
	sys_config->fs_main_ad_h = (sys_config->fs_left_fix_h-3*sys_config->fs_pad)*0.7;
	
	sys_config->fs_little_ad_w = (sys_config->fs_left_fix_w - 4*sys_config->fs_pad)/3;
	sys_config->fs_little_ad_h = sys_config->fs_left_fix_h - sys_config->fs_main_ad_h - sys_config->fs_pad;

	//right
	sys_config->fs_logo_img_w = sys_config->fs_right_fix_w;
	sys_config->fs_logo_img_h = (sys_config->fs_right_fix_h-3*sys_config->fs_pad)/4;

	sys_config->fs_code_text_h = (sys_config->fs_right_fix_h-3*sys_config->fs_pad)/16; 


	sys_config->fs_qr_img_w = sys_config->fs_right_fix_w;
	sys_config->fs_qr_img_h = (sys_config->fs_right_fix_h-3*sys_config->fs_pad)*3/16;

	sys_config->fs_usr_text_w = sys_config->fs_right_fix_w;
	sys_config->fs_usr_text_h = (sys_config->fs_right_fix_h-3*sys_config->fs_pad)/2;
	
	sys_config->fs_text_machine_id_h=sys_config->fs_pad;
	
	//set end
	SYS_LOG("sys_time_config->bs_pad[%d]\n",sys_config->fs_pad);
	SYS_LOG("sys_time_config->bs_frame_img_w[%d]\n",sys_config->fs_frame_img_w);
	SYS_LOG("sys_time_config->bs_frame_img_h[%d]\n",sys_config->fs_frame_img_h);
	SYS_LOG("sys_time_config->bs_left_fix_w[%d]\n",sys_config->fs_left_fix_w);
	SYS_LOG("sys_time_config->bs_left_fix_h[%d]\n",sys_config->fs_left_fix_h);
	SYS_LOG("sys_time_config->bs_right_fix_w[%d]\n",sys_config->fs_right_fix_w);
	SYS_LOG("sys_time_config->bs_right_fix_h[%d]\n",sys_config->fs_right_fix_h);
	SYS_LOG("sys_time_config->bs_qr_img_w[%d]\n",sys_config->fs_qr_img_w);
	SYS_LOG("sys_time_config->bs_qr_img_h[%d]\n",sys_config->fs_qr_img_h);
	SYS_LOG("sys_time_config->bs_usr_text_w[%d]\n",sys_config->fs_usr_text_w);
	SYS_LOG("sys_time_config->bs_usr_text_h[%d]\n",sys_config->fs_usr_text_h);
	SYS_LOG("sys_time_config->bs_logo_img_w[%d]\n",sys_config->fs_logo_img_w);
	SYS_LOG("sys_time_config->bs_logo_img_h[%d]\n",sys_config->fs_logo_img_h);
	SYS_LOG("sys_time_config->bs_main_ad_w[%d]\n",sys_config->fs_main_ad_w);
	SYS_LOG("sys_time_config->bs_main_ad_h[%d]\n",sys_config->fs_main_ad_h);

//wifi logo
	GtkWidget *fixed1 = GTK_WIDGET(gtk_builder_get_object (builder, "fixed1"));

	//sys_config->image_wifi = GTK_WIDGET(gtk_builder_get_object (builder, "wifi_logo"));
	//gtk_fixed_move(fixed1,sys_config->image_wifi,(sys_config->screen_w-40)/2,0);
	//update_widget_bg(sys_config->image_wifi,"./res/wifi_on.png",40,40);
	//g_signal_connect(G_OBJECT(sys_config->image_wifi), "clicked",G_CALLBACK(show_key_wifi_in_new_win), NULL);//set keyboard





//set bg
	GtkWidget *bg = GTK_WIDGET(gtk_builder_get_object (builder, "main_bg"));
	gtk_fixed_move(GTK_FIXED(fixed1),bg,0,0);
	update_widget_bg(bg,sys_config->sys_config.main_bg,sys_config->screen_w,sys_config->screen_h);

	bg = GTK_WIDGET(gtk_builder_get_object (builder, "frame_bg"));
	gtk_fixed_move(GTK_FIXED(fixed1),bg,(sys_config->screen_w-sys_config->fs_frame_img_w)/2,(sys_config->screen_h-sys_config->fs_frame_img_h)/2);
	update_widget_bg(bg,sys_config->sys_config.frame_bg,sys_config->fs_frame_img_w,sys_config->fs_frame_img_h);



	//wifi logo
		//sys_config->image_wifi = GTK_WIDGET(gtk_builder_get_object (builder, "wifi_logo"));


//message win
    create_message_win(sys_config,builder);

//set config
    create_config_win(sys_config,builder);
    bg= GTK_WIDGET(gtk_builder_get_object (builder, "config_bt"));
    gtk_widget_set_size_request(bg,10,10);
    gtk_fixed_move(GTK_FIXED(fixed1),bg,sys_config->screen_w-25,sys_config->screen_h-25);
    gtk_button_set_relief(bg,GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(bg), "clicked",G_CALLBACK(show_config_win), sys_config);//set keyboard

//set config sound
    create_config_win(sys_config,builder);
    bg= GTK_WIDGET(gtk_builder_get_object (builder, "config_sound"));
    gtk_widget_set_size_request(bg,10,10);
    gtk_fixed_move(GTK_FIXED(fixed1),bg,sys_config->screen_w-35,10);
    new_widget_bg(bg,sys_config->sys_config.image_sound,20,20);
    //gtk_button_set_relief(bg,GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(bg), "clicked",G_CALLBACK(show_config_sound_win), sys_config);//set keyboard


	//set button
	bg = GTK_WIDGET(gtk_builder_get_object (builder, "wifi_button"));
	gtk_widget_set_size_request(bg,40,40);
//	gtk_fixed_move(GTK_FIXED(fixed1),bg,(sys_config->screen_w-40)/2,0);
	gtk_fixed_move(fixed1,bg,0,sys_config->screen_h-55);
	sys_config->image_wifi = new_widget_bg(bg,sys_config->sys_config.image_wifi_off,40,40);
	g_signal_connect(G_OBJECT(bg), "clicked",G_CALLBACK(show_key_wifi_in_new_win), NULL);//set keyboard
	
	//set photo bg
		sys_config->image_photo= GTK_WIDGET(gtk_builder_get_object (builder, "image_photo"));
		gtk_fixed_move(GTK_FIXED(fixed1),sys_config->image_photo,0,0);
		gtk_widget_set_size_request(sys_config->image_photo,sys_config->screen_w,sys_config->screen_h);
		update_widget_bg(sys_config->image_photo,sys_config->sys_config.image_photo_default,sys_config->screen_w,sys_config->screen_h);

	/*
		bg = GTK_WIDGET(gtk_builder_get_object (builder, "wifi_button"));
		gtk_widget_set_size_request(bg,40,40);
		gtk_fixed_move(fixed1,bg,(sys_config->screen_w-40)/2,0);
		gtk_fixed_move(fixed1,sys_config->image_wifi,0,0);
		update_widget_bg(sys_config->image_wifi,"./res/wifi_on.png",40,40);
		gtk_container_add(GTKCONTAINER(bg),sys_config->image_wifi);
		g_signal_connect(G_OBJECT(bg), "clicked",G_CALLBACK(show_key_wifi_in_new_win), NULL);//set keyboard
*/


	GtkWidget *box1 = GTK_WIDGET(gtk_builder_get_object (builder, "box1"));
	gtk_fixed_move(GTK_FIXED(fixed1),box1,(sys_config->screen_w-sys_config->fs_frame_img_w)/2+sys_config->fs_pad,(sys_config->screen_h-sys_config->fs_frame_img_h)/2+sys_config->fs_pad);


	four_gui_builder_set_left(builder,sys_config);
	four_gui_builder_set_right(builder,sys_config);
	gtk_widget_show_all (window);

	//set jpg player
	play_jpg_player_set_image(sys_config->image_ad_main,sys_config->image_ad_left,sys_config->image_ad_middle,sys_config->image_ad_right);
	play_jpg_player();

	//set mp4 player
	player_play_mp4(sys_config->frame_movie);
	
	return window;  
}



